#ifndef SQLITEHELPER_H
#define SQLITEHELPER_H

#include <QObject>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlError>
#include <QVariant>
#include <QMutex>
#include <QThread>
#include <QDebug>

class SqliteHelper : public QObject
{
    Q_OBJECT
public:
    explicit SqliteHelper(const QString& dbPath, QObject* parent = nullptr);
    ~SqliteHelper();

    bool open();
    void close();

    bool createTable(const QString& sql);
    bool execSql(const QString& sql, const QVariantList& args = {});
    QSqlQuery query(const QString& sql, const QVariantList& args = {});
    bool deleteData(const QString& table, const QString& condition);
    bool updateData(const QString& table, const QString& setClause, const QString& condition);
    QSqlDatabase getDatabase();
private:

    QString m_dbPath;
    QMutex m_mutex;
};

#endif // SQLITEHELPER_H
